package com.heima.model.comment.pojos;

import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import com.heima.model.user.pojos.ApUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 评论表
 *
 * @author leon
 * @since 2024-11-26
 */
@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("ap_content")
@ApiModel(value="ApContent对象", description="评论表")
public class ApContent implements Serializable {

    private static final long serialVersionUID = 1L;
    public static final String COMMENT_TOPIC = "comment_topic";

    @ApiModelProperty(value = "评论的唯一标识符，使用与配置表相同的ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "评论内容")
    private String content;

    @ApiModelProperty(value = "图片链接，可以为空")
    private String image;

    @ApiModelProperty(value = "点赞数")
    private Integer likes;

    @ApiModelProperty(value = "是否为回复（0表示否）")
    private Integer reply;

    @ApiModelProperty(value = "审核标记"
            + "0 提交（待审核）"
            + "1 审核失败"
            + "2 人工审核"
            + "3 审核通过"
    )
    private Integer flag;

    @ApiModelProperty(value = "经度，可以为空")
    private BigDecimal longitude;

    @ApiModelProperty(value = "纬度，可以为空")
    private BigDecimal latitude;

    @ApiModelProperty(value = "地址信息，可以为空")
    private String address;

    @ApiModelProperty(value = "排序字段，可以为空")
    private Integer ord;

    @ApiModelProperty(value = "操作标识")
    private Integer operation;

    public static ApContent initFrom(String content, ApUser apUser) {
        return ApContent.builder()
                .content(content)
                .image(null)
                .likes(0)
                .reply(0)
                .flag(1)
                .longitude(null) //TODO 通过 redis 获取用户经纬度
                .latitude(null)
                .address(null)
                .ord(0) //TODO 没有点赞根据时间排序
                .operation(null)
                .build();
    }


}
